// my_main.c

#include "userlib.h"
#include "GenericTypeDefs.h"
#include "lib_usb_cdc.h"
#include "my_main.h"			// set desired hardware to use here


void my_main(void)
{
	unsigned char counter = 0;
	int adcValue;

// Uncomment this section to test digital inputs	

// To test this, load and run this program, then connect a jumper from eithe +V or GND to 
// PIC18 2550 chip pin 18 (RC7).  You should see the result in the least signifcant LED bit.
//
// Pins are set as input or output, then read or written, with an expression of this form:
// 
// FUNxbits.BITx# 
// where FUN = TRIS (sets bit to input or output), LAT (write), or PORT (read)
// and BIT is TRIS if FUN = TRIS, LAT if FUN = LAT, and R if FUN = PORT
// x = the port bank number, eg C for datasheet pin starting with RC, B for RB, etc
// # is the pin #, eg 7 for pin RC7

// the TRIS (tristate bits) are used to set a digital pin as input or output 
// for input, set the bit to 1; for output, set to 0
// in this example, we will use RC1 (pin 12 on the PIC18 2550 chip) as an input and display the result on RB0, LED bit 0

	TRISCbits.TRISC7 = 1;	// sets bank C, pin 7 (RC7) to input; LED pin already was set to output in main.c

// loop, reading the input pin RC7 with PORT, and writing to the LED pin with LAT
	while(1)
	{
		adcValue = PORTCbits.RC7;	// read input pin RC7
		LATBbits.LATB0 = adcValue;	// writes (displays) value read to LED pin RB0
	}
	
// end of analog to digital section

 

/* // Uncomment this section to test analog to digital inputs	

	while(1)					// loop, displaying and incrementing counter
	{
		adcValue = A2D_read(0);				
		LATB = adcValue;
		PRINTF("ctr=%d\r\n", adcValue);	
		delayT1_ms(100);		// pause for more viewable display
		
		//LATB = counter++;		// display		
		//PRINTF("ctr=%d\r\n", counter);			
		//delayT1_ms(1000);		// pause for more viewable display
		
		#ifdef USE_USB
		lib_usb_cdc_process_main();	// service the USB port
		#endif
	}	
// end of analog to digital section
*/ 


	
}

	